package hello;

/**
 * Created by abc on 10/30/16.
 */

import javax.servlet.*;
import javax.servlet.annotation.WebListener;

@WebListener
public class DynRegListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {
    }

    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext() ;
        Servlet dynRegServlet = null ;
        try {
            dynRegServlet = servletContext.createServlet(DynRegServlet.class) ;
        } catch (ServletException e) {
            e.printStackTrace();
        }
        ServletRegistration.Dynamic dynamic = servletContext.addServlet("DynRegServlet", dynRegServlet) ;
        dynamic.addMapping("/dynamic_reg") ;
    }
}